<?php if(!defined('SPRITCH')) { exit(); }

// Spritch - An opensource PHP5 web framework

// Author: Luca Degasperi
// Licence: GNU GPL
// Site: http://www.spritch.org/

// Class: Language
// Summary: This class provides internationalization functions
// Since: 0.9.1

class language extends spritch
{
	private $langs = array();
	
	public function __construct()
	{
		$this->profiler->log('language class started');
	}
	
	public function get($key,$default = false,$replace = array())
	{
		
		$key = strtoupper($key);
		$elements = explode(".",$key);		
		if(!array_key_exists($elements[0],$this->langs))
		{
			$path = $this->exists($elements[0],'languages'.DS.$this->uri->language());
			if($path)
			{
				include_once($path);
				$this->langs[$elements[0]] = $lang;
			}
		}
		if(array_key_exists($elements[1],$this->langs[$elements[0]]))
			return $this->accent($this->langs[$elements[0]][$elements[1]]);
		else
			if($default != false)
				return $default;
		return '';
	}
	
	public function to_string()
	{
		return $this->uri->language();
	}
	
	public function accent($string)
	{
		return $string;
	}
}
?>